package com.jinhe.yyds.controller;

import com.jinhe.yyds.domain.Test;
import com.jinhe.yyds.service.TestService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController  // 返回字符串
public class TestController {

    @Value("${test.hello:TEST}")
    private String testHello;

    @Resource
    private TestService testService;

    /*
    * GET POST PUT DELETE
    * */
//    @PostMapping
//    @PutMapping
//    @DeleteMapping
//    @RequestMapping(value = "/user/1",method = RequestMethod.GET)
//    @RequestMapping(value = "/user/1",method = RequestMethod.DELETE)
    @GetMapping ("/hello")
    public String hello(){
        return "jinhe" + testHello;
    }

    @PostMapping("/hello/post")
    public String helloPost(String name){
        return "jinhe post." + name;
    }

    @GetMapping ("/test/list")
    public List<Test> list() {
        return testService.list();
    }

}
